//index.js
// 获取全局应用程序实例对象
const app = getApp()

Page({
  data: {
    imgList:[],
    //是否显示面板指示点
    indicatorDots: false,
    //是否自动切换
    autoplay: true,
    //自动切换时间间隔
    interval: 2500,
    //滑动动画时长
    duration: 500
  },
  onLoad: function () {//发生页面加载时，自动触发该生命周期函数
    var that = this;
    //调用应用实例的方法获取全局数据
    app.getUserInfo(function (userInfo) {
      //更新数据，页面自动渲染
      that.setData({
        userInfo: userInfo
      })
    })

    app.network.POST(
      'https://www.ausck.com/api/banner',
      {
        params: {},
        success: function (res) {
          //拿到解密后的数据，进行代码逻辑
          if (res.data.status == 200) {
            console.log(res.data.data)
            var imgList=[];
            for (var i = 0; i < res.data.data.image.length;i++){
              imgList.push({
                image: res.data.data.image[i],
                url: res.data.data.url[i]
              })
            }
            console.log(imgList)
            that.setData({
              imgList: imgList
            })
          }
        },
        fail: function () {
          //失败后的逻辑  
        },
      })
  },
  onShow: function () {
    //返回时判断
    var info = app.globalData.info;
    if (info && !info.is_rz) {
      wx.navigateTo({
        url: "/pages/phone/phone"
      })
    }
  },
  changeIndicatorDots: function (e) {
    this.setData({
      indicatorDots: !this.data.indicatorDots
    })
  },
  changeAutoplay: function (e) {
    this.setData({
      autoplay: !this.data.autoplay
    })
  },

  intervalChange: function (e) {
    this.setData({
      interval: e.detail.value
    })
  },
  durationChange: function (e) {
    this.setData({
      duration: e.detail.value
    })
  },
  toVehicleInformation: function () {
    wx.navigateTo({
      url: "/pages/vehicle-information/vehicle-information"
    })
  },
  toPersonalInformation: function () {
    wx.navigateTo({
      url: "/pages/personal-information/personal-information"
    })
  },
  toRecharge: function () {
    wx.navigateTo({
      url: "/pages/recharge/recharge"
    })
  },
  toMyorder: function () {
    wx.navigateTo({
      url: "/pages/myorder/myorder?id=5"
    })
  },
  toCustomerService: function () {
    wx.navigateTo({
      url: "/pages/customer-service/customer-service?index=0"
    })
  },
  toProcess: function () {
    wx.navigateTo({
      url: "/pages/process/process"
    })
  },
  toCooperation: function () {
    wx.navigateTo({
      url: "/pages/cooperation/cooperation"
    })
  },
  onItemClick: function (event) {
    var url=event.target.dataset.url
    if (url) {
      wx.navigateTo({
        url: "/pages/wailian/wailian?src=" + url
      })
    }
  }
})



